package cn.jinbyte.core.handler.masking;

import cn.hutool.core.util.DesensitizedUtil;

/**
 * 脱敏策略
 */
public enum MaskingStrategy {
    FULL_MASK {
        @Override
        public String mask(String content) {
            if (content == null) return null;
            return content.replaceAll("\\.", "*");
        }
    },
    PHONE {
        @Override
        public String mask(String content) {
            return DesensitizedUtil.desensitized(content, DesensitizedUtil.DesensitizedType.MOBILE_PHONE);
        }
    },
    EMAIL {
        @Override
        public String mask(String content) {
            return DesensitizedUtil.desensitized(content, DesensitizedUtil.DesensitizedType.EMAIL);
        }
    },
    ID_CARD {
        @Override
        public String mask(String content) {
            return DesensitizedUtil.desensitized(content, DesensitizedUtil.DesensitizedType.ID_CARD);
        }
    };

    public abstract String mask(String content);
}
